<!DOCTYPE html>
<html>
<head>
<title></title>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">


<!--
	描述：js导入，注意顺序，jquery必须引入
	bootstrap-table-zh-CN.js为表格汉化的文件
	FileSaver.min.js等是关联引用文件
-->

<script type="text/javascript" src="../assets/plugins/boostraptable/dist/bootstrap-table.js"></script>
<script type="text/javascript" src="../assets/plugins/boostraptable/dist/bootstrap-table-locale-all.min.js"></script>
<link href="../assets/plugins/bootstrap3-editable/css/bootstrap-editable.css" rel="stylesheet">
<script src="../assets/plugins/bootstrap3-editable/js/bootstrap-editable.js"></script>
<script src="../assets/plugins/boostraptable/dist/extensions/editable/bootstrap-table-editable.js"></script>



</head>
<body>
<div id="app_dialog" class="content-div">

	    <!-- 查询块 end -->
	    <table id="table_dialog"></table>
	    <!-- 列表table显示end -->	    
</div>

<script>

var result = [];
$.ajax({
    url: $path+'/sys/generator/list?page=1&limit=500',
    async: false,
    type: "get",
    data: {},
    success: function (data, status) {
    	var list = data.page.list;
    	result.push({ value: "", text: "" });
        $.each(list, function (key, value) {
            result.push({ value: value.TABLENAME, text: value.TABLENAME });
        });
    }
});


var baseDataType = [];
$.ajax({
    url: $path+'/sys/sysbasedatatype/list?noPage=1&parentId=1',
    async: false,
    type: "get",
    data: {},
    success: function (data, status) {
    	var list = data.page.list;
    	baseDataType.push({ value: "", text: "" });
    	$.each(list, function (key, value) {
            baseDataType.push({ value:value.baseTypeKey, text:value.baseTypeName });
        });
    }
});

$(function () {

	
	//$.fn.editable.defaults.mode = 'inline';//编辑方式为内联方式
	$.fn.editable.defaults.showbuttons = false;    //不显示按钮组.
    $.fn.editable.defaults.onblur ="submit";    //当焦点离开时以提交处理,默认是取消.
    dialogTable = $('#table_dialog').bootstrapTable({
        url: $path+"/sys/generator/tableList",
        cache: false,
        striped: true,                              //是否显示行间隔色
        sidePagination: "server",
        showColumns:false,
        pagination:false,
        minimumCountColumns:2,
        pageNumber:1,                       //初始化加载第一页，默认第一页
        pageSize: 10,                       //每页的记录行数（*）
        pageList: [10, 15, 20, 25],        //可供选择的每页的行数（*）
        showExport: false,                    
        onEditableSave: function (field, row, oldValue, $el) {
           // alert("编辑成功");
        },
        queryParams:{"tableName":tableName},
        columns: [
        {
	        field: 'COLUMNNAME',
	        title: '属性名'
	    },
        {
	        field: 'COLUMNCOMMENT',
	        title: '显示名',
            editable: {
				type: 'text',  				
			} 
	    },
	    {
	        field: 'search',
	        title: '是否搜索',
            editable: {
				type: 'select',
				pk: 1,
		        source: [
		            {value: 0, text: ''},
		            {value: 1, text: '输入框'},
		            {value: 2, text: '下拉框'},
		        ]
			}
	    },
	    {
	        field: 'displayList',
	        title: '是否显示列表项',
            editable: {
				type: 'select',
				pk: 1,
		        source: [
		            {value: 0, text: ''},
		            {value: 1, text: '普通列'},
		            {value: 2, text: '状态列'},
		            {value: 3, text: '名字列[关联表]'},
		        ]
			}
	    },
	    {
	        field: 'editType',
	        title: '是否可编辑',
            editable: {
				type: 'select',
				pk: 1,
		        source: [
		            {value: 0, text: ''},
		            {value: 1, text: '输入框'},
		            {value: 2, text: '下拉框'},
		            {value: 3, text: '单选框'},
		            {value: 4, text: '复选框'},
		            {value: 5, text: '文本框'},
		            {value: 6, text: '关联选择-单选'},
		            {value: 7, text: '关联选择-多选'},
		            {value: 8, text: '开始时间'},
		            {value: 9, text: '结束时间'},
		        ]
			},
			
	    },
	    {
	        field: 'assTable',
	        title: '关联表',
            editable: {
				type: 'select',
				pk: 1,
		        source: result
			},
			
	    },
	    {
	        field: 'assBaseData',
	        title: '关联基础数据',
            editable: {
				type: 'select',
				pk: 1,
		        source: baseDataType
			},
	    },
        {
	        field: 'vaild',
	        title: '是否较验',
            editable: {
				type: 'select',				
		        source: [
		            {value: 0, text: ''},
		            {value: 1, text: '非空'},
		            {value: 2, text: '长度限制'},
		            {value: 3, text: '非空长度限制'},
		            {value: 4, text: '正则表达式'},
		            {value: 5, text: '非空正则表达式'},
		            {value: 6, text: '验重复(非空,长度限制)'},
		            
		        ]
			}
	    },
	    {
	        field: 'midAssTable',
	        title: '中间表',
            editable: {
				type: 'select',
				pk: 1,
		        source: result
			},
	    },
        {
	        field: 'vaildValue',
	        title: '正则表达式',
            editable: {
				type: 'text',  				
			} 
	    }],
	    responseHandler: function(res) {
        	   if(res.page ==null){
        		   if(res.code == 400){
        			   alert(res.msg);
        		   }
        		   return {
                       "total": 0,//总数
                       "rows":  null   //数据
                     };
        	   }else{
        		   $.each(res.page.list, function (i, row) {
                	  //console.log(row[idField]);
                	 //  row.id = ""+row[idField];
                      // row.state = $.inArray(row.id, selectionIds) != -1;  
                   });
                   return {
                      "total": res.page.totalCount,//总数
                      "rows":  res.page.list   //数据
                    };
        	   }
               
       }
	});

	 
});

/*$(function () {
	
	$.fn.editable.defaults.mode = 'inline';//编辑方式为内联方式
	
    var columns =[
					
					{
	        field: 'COLUMNNAME',
	        title: '性别',
            editable: {
				type: 'select',
				pk: 1,
		        source: [
		            {value: 1, text: '男'},
		            {value: 2, text: '女'},
		        ],
		        noeditFormatter: function (value,row,index) {
                    var result={filed:"sex",value:value,class:"badge",style:"background:#333;padding:5px 10px;"};
                    return result;
                }
			}
	    },
					{field: 'companyName' , formatter: 'companyFormatter', title: "busCompanyField.companyName", sortName:'company_name' , sortable: false,halign: 'center',align: 'center'},
					{field: 'companyId' , title:  "", sortName:'company_id' , sortable: false,halign: 'center',align: 'center'},
					{field: 'status' , title: "", formatter:'statusFormatter', sortName:'status' , sortable: false,halign: 'center',align: 'center'},
					{field: 'creator.username' , title: "", sortName:'create_user_id' , sortable: false,halign: 'center',align: 'center'},
		         ];
	 $table_dialog = new EditTable("table_dialog", 'http://10.10.2.60:8099/tvrps2.0/sys/generator/tableList', columns,'',430,'companyNo','COMPANY_NO','buscompany',true,'companyName');

	 var queryParams = function(params) {		
	     return {
		         	  page: params.pageNumber,
		         	  limit: params.pageSize,
		         	  sidx: params.sortName,
		              order: params.sortOrder,
	         };
	 };    
	 $table_dialog.setQueryParams(queryParams);
	 $table_dialog.init();
	 
});*/


</script>
</body>
</html>